package com.EpidemicPrevention.controller;

import com.EpidemicPrevention.pojo.Sign;
import com.EpidemicPrevention.service.SignServiceImpl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/SignController")
public class SignController {
    @Autowired
    private SignServiceImpl signService;

    //    存储用户信息
//    @Param user
//    @return
    @GetMapping("/saveSign")
    @ResponseBody
    @CrossOrigin
    public JSON saveSign (Sign sign) {
        return  signService.saveSign (sign);
    }

    @GetMapping("/deleteSign")
    @ResponseBody
    @CrossOrigin
    public JSON deleteSign(int s_id) {
        return signService.deleteSign (s_id);
    }

    @GetMapping("/querySign")
    @ResponseBody
    @CrossOrigin
    public JSON queryItem_info(@RequestParam("page") int page, @RequestParam("limit") int limit) {
        JSONObject json = new JSONObject();
        int page1 = page - 1;
        int page2 = page1 * limit;
        json.put("code", 1);
        json.put("msg", "");
        json.put("count", signService.querySign (0, 100,null).size());
        json.put("data",signService.querySign(page2, limit,null));
        return json;
    }

}
